package com.feicheng.lanniao.service.impl;

import com.feicheng.lanniao.entity.SysImage;
import com.feicheng.lanniao.exception.SystemException;
import com.feicheng.lanniao.mapper.SysImageMapper;
import com.feicheng.lanniao.result.ResultInfo;
import com.feicheng.lanniao.service.SysImageService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @Author tianchunlei
 * @Des //图片上传控制图片个数的业务实现类
 * @Date 2021/9/24
 **/
@Service
public class SysImageServiceImpl implements SysImageService {

    @Resource
    private SysImageMapper sysImageMapper;

    /**
     * @Author tianchunlei
     * @Description //查询图片上传个数的集合
     * @Date 2021/9/24 11:03
     * @Param
     * @return ResultInfo
     */
    @Override
    public ResultInfo list() {
        return ResultInfo.success(sysImageMapper.selectList(null));
    }

    /**
     * @Author tianchunlei
     * @Description //修改图片上传的个数
     * @Date 2021/9/24 11:03
     * @Param
     * @return
     */
    @Override
    public ResultInfo update(SysImage sysImage) {
        if (sysImageMapper.updateById(sysImage) == 0) {
            throw new SystemException("修改上传图片个数更新失败");
        }
        return ResultInfo.success();
    }

    /**
     * @Author tianchunlei
     * @Description //按照id查询上传图片的个数的单条记录
     * @Date 2021/9/24 11:57
     * @Param 主键id
     * @return ResultInfo
     */
    @Override
    public ResultInfo selectById(Integer id) {
        SysImage sysImage = sysImageMapper.selectById(id);
        return ResultInfo.success(sysImage);
    }
}
